/*  Copyright (C) 2012 Philip Smith
 *
 *  This file is part of SuperChat.
 *
 *  SuperChat is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  SuperChat is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with SuperChat.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.supertycoon.bukkit.superchat;

import java.util.Arrays;
import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class chatCommandHandler implements CommandExecutor {

	String[] illegalGroupNames = new String[] { "join", "create", "list", "quit", "split", "flip", "move", "chat", "monitor", "force",
			"kick", "lookup", "close", "all", "main", "off", "hidden" };
	String[] forbiddenRoomNames = new String[] { "mod" };

	@Override
	public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
		if (arg3.length > 0) {
			// superchat.user.join
			if (arg3[0].equalsIgnoreCase("join") || arg3[0].equalsIgnoreCase("j")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.join")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to join chat rooms");
					return true;
				}
				if (arg3.length == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify which room to join");
					return true;
				}
				if (arg3[1].equalsIgnoreCase("main")) {
					if (SuperChat.players.containsKey(arg0) && SuperChat.players.get(arg0).isIgnoringMain) {
						SuperChat.players.get(arg0).stopIgnoringMain();
						return true;
					}
					arg0.sendMessage(ChatColor.RED.toString() + "You are already in the main chat");
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[1]);
				if (room == null) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				if (room.modroom && (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.modroom"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission for this chat room");
					return true;
				}
				if (SuperChat.players.containsKey(arg0) && SuperChat.players.get(arg0).isMember(room)) {
					arg0.sendMessage(ChatColor.RED.toString() + "You are already in the chat room \"" + room.name + '"');
					return true;
				}
				if (room.password == null || (arg3.length > 2 && arg3[2].equals(room.password))
						|| !(arg0 instanceof Player) || arg0.hasPermission("superchat.mod.ignorepass")) {
					room.addPlayer(arg0);
					if (!SuperChat.players.containsKey(arg0))
						SuperChat.players.put(arg0, new PlayerShit(arg0));
					SuperChat.players.get(arg0).addChatRoom(room);
					return true;
				}
				arg0.sendMessage(ChatColor.RED.toString() + "Incorrect or no password supplied");
				return true;
				// superchat.user.create
			} else if (arg3[0].equalsIgnoreCase("create") || arg3[0].equalsIgnoreCase("c")) {
				if (arg0 instanceof Player
						&& (!arg0.hasPermission("superchat.user.join") || !arg0.hasPermission("superchat.user.create"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to create chat rooms");
					return true;
				}
				if (arg3.length == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify a room name");
					return true;
				}
				if (arg3[1].length() == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "Room names must be at least two characters long");
					return true;
				}
				for (String illegal : this.illegalGroupNames) {
					if (arg3[1].equalsIgnoreCase(illegal)) {
						arg0.sendMessage(ChatColor.RED.toString() + "Specified name cannot be used");
						return true;
					}
				}
				for (String illegal : this.forbiddenRoomNames) {
					if (arg3[1].equalsIgnoreCase(illegal)) {
						arg0.sendMessage(ChatColor.RED.toString() + "Specified name cannot be used");
						return true;
					}
				}
				if (SuperChat.rooms.containsKey(arg3[1])) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room already exists");
					return true;
				}
				String password = null;
				if (arg3.length > 2)
					password = arg3[2];
				SuperChat.rooms.put(arg3[1], new ChatRoom(arg3[1], password, false));
				arg0.sendMessage(ChatColor.GRAY.toString() + "Chat room \"" + arg3[1] + "\" created"
						+ (password == null ? "" : " with password \"" + password + '"'));
				SuperChat.rooms.get(arg3[1]).addPlayer(arg0);
				if (!SuperChat.players.containsKey(arg0))
					SuperChat.players.put(arg0, new PlayerShit(arg0));
				SuperChat.players.get(arg0).addChatRoom(SuperChat.rooms.get(arg3[1]));
				return true;
			} else if (arg3[0].equalsIgnoreCase("list") || arg3[0].equalsIgnoreCase("l")) {
				// superchat.user.list.self
				if (arg3.length == 1) {
					if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.list.self")) {
						arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to list your joined chat rooms");
						return true;
					}
					if (!SuperChat.players.containsKey(arg0)) {
						arg0.sendMessage(ChatColor.GRAY + "You are only in the main chat");
						return true;
					}
					StringBuilder output = new StringBuilder();
					if (SuperChat.players.get(arg0).isIgnoringMain) {
						output.append("[");
					} else {
						output.append("[ main");
					}
					for (ChatRoom room : SuperChat.players.get(arg0).primary) {
						output.append(' ' + room.name);
					}
					for (ChatRoom room : SuperChat.players.get(arg0).secondary) {
						output.append(' ' + room.name);
					}
					arg0.sendMessage(ChatColor.GRAY.toString() + "You are currently in: " + output + " ]");
					return true;
				}
				// superchat.user.list.all
				if (arg3[1].equalsIgnoreCase("all")) {
					if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.list.all")) {
						arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to list all chat rooms");
						return true;
					}
					StringBuilder output = new StringBuilder("[");
					for (ChatRoom room : SuperChat.rooms.values())
						output.append(' ' + room.name);
					arg0.sendMessage(ChatColor.GRAY.toString() + "The following chat rooms exist: " + output + " ]");
					return true;
				}
				// superchat.user.list.room
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.list.room")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to list room members");
					return true;
				}
				if (!SuperChat.rooms.containsKey(arg3[1])) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[1]);
				if (room.modroom && (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.modroom"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission for this chat room");
					return true;
				}
				if (room.password == null || (arg3.length > 2 && arg3[2].equals(room.password))
						|| !(arg0 instanceof Player) || arg0.hasPermission("superchat.mod.ignorepass")) {
					StringBuilder output = new StringBuilder("[");
					for (CommandSender player : room.players)
						output.append(' ' + player.getName());
					arg0.sendMessage(ChatColor.GRAY.toString() + "The following players are in chat room \"" + room.name
							+ "\" : " + output + " ]");
					return true;
				}
				arg0.sendMessage(ChatColor.RED.toString() + "Incorrect or no password supplied");
				return true;
				// superchat.user.quit
			} else if (arg3[0].equalsIgnoreCase("quit") || arg3[0].equalsIgnoreCase("q")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.quit")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to quit chat rooms");
					return true;
				}
				if (arg3.length == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify which room to quit");
					return true;
				}
				if (arg3[1].equalsIgnoreCase("main")) {
					if (!(arg0 instanceof Player)) {
						arg0.sendMessage(ChatColor.RED.toString() + "Only Players can quit the main chat");
						return true;
					}
					if (!SuperChat.players.containsKey(arg0))
						SuperChat.players.put(arg0, new PlayerShit(arg0));
					if (SuperChat.players.get(arg0).isIgnoringMain) {
						arg0.sendMessage(ChatColor.RED.toString() + "You have already quit the main chat");
						return true;
					}
					SuperChat.players.get(arg0).ignoreMain();
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[1]);
				if (room == null) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				if (!SuperChat.players.containsKey(arg0) || !SuperChat.players.get(arg0).isMember(room)) {
					arg0.sendMessage(ChatColor.RED.toString() + "You are not in the chat room \"" + room.name + '"');
					return true;
				}
				room.removePlayer(arg0);
				SuperChat.players.get(arg0).quitChatRoom(room);
				return true;
				// superchat.user.toggle
			} else if (arg3[0].equalsIgnoreCase("toggle") || arg3[0].equalsIgnoreCase("t")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.toggle")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to toggle chat rooms");
					return true;
				}
				if (!(arg0 instanceof Player)) {
					arg0.sendMessage(ChatColor.RED.toString() + "Only Players can toggle");
					return true;
				}
				if (arg3.length == 1 || arg3[1].equalsIgnoreCase("off")) {
					if (!SuperChat.players.containsKey(arg0) || SuperChat.players.get(arg0).toggle == null) {
						arg0.sendMessage(ChatColor.RED.toString() + "You do not have a chat room toggle to disable");
						return true;
					}
					SuperChat.players.get(arg0).disableToggle();
					return true;
				}
				if (arg3[1].equalsIgnoreCase("main")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You cannot toggle for main chat");
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[1]);
				if (room == null) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				if ((!SuperChat.players.containsKey(arg0) || !SuperChat.players.get(arg0).isMember(room)) && !arg0.hasPermission("superchat.mod.chatwojoin") ) {
					arg0.sendMessage(ChatColor.RED.toString() + "You are not in the chat room \"" + room.name + '"');
					return true;
				}
				if (!SuperChat.players.containsKey(arg0))
					SuperChat.players.put(arg0, new PlayerShit(arg0));
				SuperChat.players.get(arg0).toggle(room);
				return true;
				// superchat.mod.monitor
			} else if (arg3[0].equalsIgnoreCase("monitor")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.monitor")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to monitor chat rooms");
					return true;
				}
				if (!SuperChat.players.containsKey(arg0))
					SuperChat.players.put(arg0, new PlayerShit(arg0));
				if (arg3.length > 1) {
					if (arg3[1].equalsIgnoreCase("on") || arg3[1].equals("1")) {
						SuperChat.monitors.add(arg0);
						arg0.sendMessage(ChatColor.GRAY.toString() + "SuperChat monitoring set to ON");
						return true;
					} else if (arg3[1].equalsIgnoreCase("off") || arg3[1].equals("0")) {
						SuperChat.monitors.remove(arg0);
						arg0.sendMessage(ChatColor.GRAY.toString() + "SuperChat monitoring set to OFF");
						return true;
					}
				}
				if (SuperChat.monitors.contains(arg0)) {
					SuperChat.monitors.remove(arg0);
					arg0.sendMessage(ChatColor.GRAY.toString() + "SuperChat monitoring toggled to OFF");
					return true;
				}
				SuperChat.monitors.add(arg0);
				arg0.sendMessage(ChatColor.GRAY.toString() + "SuperChat monitoring toggled to ON");
				return true;
				// superchat.mod.force
			} else if (arg3[0].equalsIgnoreCase("force")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.force")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to force chat room joins");
					return true;
				}
				if (arg3.length < 3) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify a player and chat room");
					return true;
				}
				List<Player> pdump = Bukkit.matchPlayer(arg3[1]);
				if (pdump.isEmpty()) {
					arg0.sendMessage(ChatColor.RED.toString() + "No player found with that name");
					return true;
				}
				if (pdump.size() > 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "Multiple players found with that name");
					return true;
				}
				if (arg3[2].equalsIgnoreCase("main")) {
					if (SuperChat.players.containsKey(pdump.get(0)) && SuperChat.players.get(pdump.get(0)).isIgnoringMain) {
						SuperChat.players.get(pdump.get(0)).stopIgnoringMain();
						arg0.sendMessage(ChatColor.GRAY.toString() + "Player \"" + pdump.get(0).getName()
								+ "\" has rejoined the main chat");
						return true;
					}
					arg0.sendMessage(ChatColor.RED.toString() + "Player \"" + pdump.get(0).getName()
							+ "\" is already in the main chat");
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[2]);
				if (room == null) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				if (room.modroom && (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.modroom"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission for this chat room");
					return true;
				}
				if (room.password == null || (arg3.length > 3 && arg3[3].equals(room.password))
						|| !(arg0 instanceof Player) || arg0.hasPermission("superchat.mod.ignorepass")) {
					room.addPlayer(pdump.get(0));
					if (!SuperChat.players.containsKey(pdump.get(0)))
						SuperChat.players.put(pdump.get(0), new PlayerShit(pdump.get(0)));
					SuperChat.players.get(pdump.get(0)).addChatRoom(room);
					arg0.sendMessage(ChatColor.GRAY.toString() + "Player \"" + pdump.get(0).getName()
							+ "\"  joined the chat room \"" + room.name + '"');
					return true;
				}
				arg0.sendMessage(ChatColor.RED.toString() + "Incorrect or no password supplied");
				return true;
				// superchat.mod.kick
			} else if (arg3[0].equalsIgnoreCase("kick")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.kick")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to force chat room quits");
					return true;
				}
				if (arg3.length < 3) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify a player and chat room");
					return true;
				}
				List<Player> pdump = Bukkit.matchPlayer(arg3[1]);
				if (pdump.isEmpty()) {
					arg0.sendMessage(ChatColor.RED.toString() + "No player found with that name");
					return true;
				}
				if (pdump.size() > 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "Multiple players found with that name");
					return true;
				}
				if (arg3[2].equalsIgnoreCase("main")) {
					if (!SuperChat.players.containsKey(pdump.get(0)))
						SuperChat.players.put(pdump.get(0), new PlayerShit(pdump.get(0)));
					if (SuperChat.players.get(pdump.get(0)).isIgnoringMain) {
						arg0.sendMessage(ChatColor.RED.toString() + "Player \"" + pdump.get(0).getName()
								+ "\" has already quit the main chat");
						return true;
					}
					SuperChat.players.get(pdump.get(0)).ignoreMain();
					arg0.sendMessage(ChatColor.GRAY.toString() + "Player \"" + pdump.get(0).getName()
							+ "\" has quit the main chat");
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[2]);
				if (room == null) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				if (room.modroom && (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.modroom"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission for this chat room");
					return true;
				}
				if (room.password == null || (arg3.length > 3 && arg3[3].equals(room.password))
						|| !(arg0 instanceof Player) || arg0.hasPermission("superchat.mod.ignorepass")) {
					if (!SuperChat.players.containsKey(pdump.get(0)) || !SuperChat.players.get(pdump.get(0)).isMember(room)) {
						arg0.sendMessage(ChatColor.RED.toString() + "Player \"" + pdump.get(0).getName()
								+ "\" is not in the chat room \"" + room.name + '"');
						return true;
					}
					room.removePlayer(pdump.get(0));
					SuperChat.players.get(pdump.get(0)).quitChatRoom(room);
					arg0.sendMessage(ChatColor.GRAY.toString() + "Player \"" + pdump.get(0).getName()
							+ "\" quit the chat room \"" + room.name + '"');
					return true;
				}
				arg0.sendMessage(ChatColor.RED.toString() + "Incorrect or no password supplied");
				return true;
				// superchat.mod.lookup
			} else if (arg3[0].equalsIgnoreCase("lookup")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.lookup")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to lookup players");
					return true;
				}
				if (arg3.length < 2) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify a player");
					return true;
				}
				List<Player> pdump = Bukkit.matchPlayer(arg3[1]);
				if (pdump.isEmpty()) {
					arg0.sendMessage(ChatColor.RED.toString() + "No player found with that name");
					return true;
				}
				if (pdump.size() > 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "Multiple players found with that name");
					return true;
				}
				if (!SuperChat.players.containsKey(pdump.get(0))) {
					arg0.sendMessage(ChatColor.GRAY + "Player \"" + pdump.get(0).getName()
							+ "\" is only in the main chat");
					return true;
				}
				StringBuilder output = new StringBuilder();
				if (SuperChat.players.get(pdump.get(0)).isIgnoringMain) {
					output.append("[");
				} else {
					output.append("[ main");
				}
				for (ChatRoom room : SuperChat.players.get(pdump.get(0)).primary) {
					output.append(' ' + room.name);
				}
				for (ChatRoom room : SuperChat.players.get(pdump.get(0)).secondary) {
					output.append(' ' + room.name);
				}
				arg0.sendMessage(ChatColor.GRAY + "Player \"" + pdump.get(0).getName()
						+ "\" is currently in: " + output + " ]");
				return true;
				// superchat.mod.close
			} else if (arg3[0].equalsIgnoreCase("close")) {
				if (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.close")) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to close chat rooms");
					return true;
				}
				if (arg3.length == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify a room name");
					return true;
				}
				ChatRoom room = SuperChat.rooms.get(arg3[1]);
				if (room == null) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
					return true;
				}
				if (room.modroom && (arg0 instanceof Player && !arg0.hasPermission("superchat.mod.modroom"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission for this chat room");
					return true;
				}
				if (room.password == null || (arg3.length > 3 && arg3[3].equals(room.password))
						|| !(arg0 instanceof Player) || arg0.hasPermission("superchat.mod.ignorepass")) {
					room.close();
					arg0.sendMessage(ChatColor.GRAY.toString() + "Chat room \"" + arg3[1] + "\" closed");
					return true;
				}
				arg0.sendMessage(ChatColor.RED.toString() + "Incorrect or no password supplied");
				return true;
				// superchat.mod.createmod
			} else if (arg3[0].equalsIgnoreCase("createmod")) {
				if (arg0 instanceof Player
						&& (!arg0.hasPermission("superchat.user.join") || !arg0.hasPermission("superchat.user.create") || !arg0.hasPermission("superchat.mod.modroom"))) {
					arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to create mod chat rooms");
					return true;
				}
				if (arg3.length == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "You must specify a room name");
					return true;
				}
				if (arg3[1].length() == 1) {
					arg0.sendMessage(ChatColor.RED.toString() + "Room names must be at least two characters long");
					return true;
				}
				for (String illegal : this.illegalGroupNames) {
					if (arg3[1].equalsIgnoreCase(illegal)) {
						arg0.sendMessage(ChatColor.RED.toString() + "Specified name cannot be used");
						return true;
					}
				}
				if (SuperChat.rooms.containsKey(arg3[1])) {
					arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room already exists");
					return true;
				}
				String password = null;
				if (arg3.length > 2)
					password = arg3[2];
				SuperChat.rooms.put(arg3[1], new ChatRoom(arg3[1], password, true));
				arg0.sendMessage(ChatColor.GRAY.toString() + "Mod chat room \"" + arg3[1] + "\" created"
						+ (password == null ? "" : " with password \"" + password + '"'));
				SuperChat.rooms.get(arg3[1]).addPlayer(arg0);
				if (!SuperChat.players.containsKey(arg0))
					SuperChat.players.put(arg0, new PlayerShit(arg0));
				SuperChat.players.get(arg0).addChatRoom(SuperChat.rooms.get(arg3[1]));
				return true;
			}
			// DEFAULT -- chat to room
			if (arg0 instanceof Player && !arg0.hasPermission("superchat.user.chat")) {
				arg0.sendMessage(ChatColor.RED.toString() + "You do not have permission to chat");
				return true;
			}
			if (arg3[0].equalsIgnoreCase("main")) {
				if (!(arg0 instanceof Player)) {
					arg0.sendMessage(ChatColor.RED.toString() + "Only Players can chat in the main chat");
					return true;
				}
				((Player) arg0).chat(SuperChat.concat(Arrays.copyOfRange(arg3, 1, arg3.length), " "));
				return true;
			}
			ChatRoom room = SuperChat.rooms.get(arg3[0]);
			if (room == null) {
				arg0.sendMessage(ChatColor.RED.toString() + "Specified chat room does not exist");
				return true;
			}
			if (!SuperChat.players.containsKey(arg0))
				SuperChat.players.put(arg0, new PlayerShit(arg0));
			if (!SuperChat.players.get(arg0).isMember(room) && !arg0.hasPermission("superchat.mod.chatwojoin")) {
				arg0.sendMessage(ChatColor.RED.toString() + "You are not in the specified chat room");
				return true;
			}
			SuperChat.players.get(arg0).last = room;
			room.chat(ChatColor.GRAY.toString() + '[' + arg0.getName() + ']' + ' ' + ChatColor.WHITE
					+ SuperChat.concat(Arrays.copyOfRange(arg3, 1, arg3.length), " "));
		}
		return false;
	}

}
